package com.woniu.communitymanagement.controller;

import com.woniu.communitymanagement.entity.Carcharge;
import com.woniu.communitymanagement.entity.HttpResult;
import com.woniu.communitymanagement.service.CarchargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/carCharge")
@CrossOrigin(origins = "*")
public class CarChargeController {
    @Autowired
    private CarchargeService carchargeService;

    /**
     *
     * @param id
     * @return
     */
    @RequestMapping("delete")
    public HttpResult deleteById(Integer id){
        return carchargeService.deleteById(id);
    }

    /**
     * {
     *   "id": 11,
     *   "payDate": "2022-11-28",
     *   "endDate": "2022-11-30",
     *   "money": 200.0,
     *   "status": 1,
     *   "ownerId": 9,
     *   "remarks": "111",
     *   "type": "停车费",
     *   "parkId": 3
     * }
     * @param carcharge
     * @return
     */
    @RequestMapping("/update")
    public HttpResult updateById(@RequestBody Carcharge carcharge){
        return carchargeService.updateCarcharge(carcharge);
    }

    /**
     * {
     *   "payDate": "2022-11-30",
     *   "endDate": "2022-11-30",
     *   "money": 200.0,
     *   "status": 1,
     *   "ownerId": 9,
     *   "remarks": "无",
     *   "type": "停车费",
     *   "parkId": 3
     * }
     * @param carcharge
     * @return
     */
    @RequestMapping("/insert")
    public HttpResult insertOne(@RequestBody Carcharge carcharge){
        return carchargeService.insertOne(carcharge);
    }

    /**
     * http://localhost:8080/carCharge/selectOne?id=3
     * @param id
     * @return
     */
    @RequestMapping("/selectOne")
    public HttpResult selectOneById(Integer id){
        return carchargeService.selectOneById(id);
    }
    @RequestMapping("/list")
    public HttpResult getCarchargeList(String parkingNumbers,String carChargeStatus,Integer pageIndex,Integer pageSize){
        return carchargeService.getCarChargeList(parkingNumbers,carChargeStatus,pageIndex,pageSize);
    }
    @RequestMapping("/all")
    public HttpResult all(){
        return carchargeService.getall();
    }

}
